﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using SystemModel;
using BangleCMS.Model;
using System.Collections;

namespace BangleCMS.BLL
{
    /// <summary>
    /// sys_userBLL
    /// </summary>
    public partial class sys_userBLL
    {
        public UserSession UserLogin(string Account, string Password)
        {
            UserSession Session = new UserSession();
            sys_user model = dal.UserLogin(Account, Password);

            if (model == null)
            {
                return null;
            }

            Session.LoginName = model.LoginName;
            Session.PageSize = 10;
            Session.RoleId = model.RoleId;
            Session.UserID = model.UserId;
            Session.UserName = model.UserName;

            IDictionary<string, string> UserMenu = new Dictionary<string, string>();

            List<view_rolemenu_list> list = new List<view_rolemenu_list>();
            view_rolemenu_listBLL bll = new view_rolemenu_listBLL();
            list = bll.GetModelList("RoleId=" + Session.RoleId.ToString());

            for (int i = 0; i < list.Count; i++)
            {
                UserMenu.Add(list[i].MenuCode, list[i].ModularId.ToString());
            }

            Session.UserMenu = UserMenu;
            
            return Session;
        }
    }
}
